def log_getattribute(cls):
    orig_getattribute = cls.__getattribute__

    def new_getattribute(self, name, *args, **kwargs):
        print(self)
        print('getting: {}'.format(name))
        return orig_getattribute(self, name, *args, **kwargs)

    cls.__getattribute__ = new_getattribute
    return cls


@log_getattribute
class A:
    def __init__(self, x):
        self.x = x

    def method(self):
        pass

    pass


if __name__ == '__main__':
    a = A(x=5)
    print(a.x)
    a.method()
